Skip to content

Conversation

@JDPailleux
Copy link
Contributor

Normally fix incorrect linking introduced in #161179 with build in parallel.

@JDPailleux JDPailleux requested a review from pawosm-arm October 23, 2025 16:25
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir labels Oct 23, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 23, 2025

@llvm/pr-subscribers-flang-fir-hlfir

Author: Jean-Didier PAILLEUX (JDPailleux)

Changes

Normally fix incorrect linking introduced in #161179 with build in parallel.


Full diff: https://github.com/llvm/llvm-project/pull/164841.diff

1 Files Affected:

  • (modified) flang/lib/Optimizer/Dialect/MIF/CMakeLists.txt (-1)
diff --git a/flang/lib/Optimizer/Dialect/MIF/CMakeLists.txt b/flang/lib/Optimizer/Dialect/MIF/CMakeLists.txt
index ed8463e9b0330..d53937ebb49d4 100644
--- a/flang/lib/Optimizer/Dialect/MIF/CMakeLists.txt
+++ b/flang/lib/Optimizer/Dialect/MIF/CMakeLists.txt
@@ -8,7 +8,6 @@ add_flang_library(MIFDialect
   LINK_LIBS
   FIRDialect
   FIRDialectSupport
-  FIRSupport
 
   LINK_COMPONENTS
   AsmParser

@pawosm-arm
Copy link
Contributor

This PR looks weird (removing things rather than adding to the CMakefile), but somehow it made our CI green. Note that I had to test for the other issue alongside, so it wasn't the recommended 'change one thing at a time' approach.

Copy link
Contributor

@tblah tblah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for taking time for looking into this but I don't think this is the whole right fix yet. The error message in #164630 would indicate a missing dependency between whatever is including MIFDialect.h and the CMake task which is generating the table gen parts of that header (MIFDialect).

I had a quick look and I see that the header file is included from flang/include/flang/Optimizer/Support/InitFIR.h. FIRSupport has no dependency upon MIFDialect and so there is no guarantee that it will be built after MIFDialect.

I think removing the dependency from MIFDialect to FIRSupport makes the issue much less likely (because CMake won't be trying to build FIRSupport before it has built MIFDialect) but it doesn't guarantee that the build order will be correct in the future for all machines.

Beware that the dependency is created by the presence of the include in a header (InitFIR.h) and so every library that includes InitFIR.h will also depend upon MIFDialect. However, they should already have a dependency on FIRSupport so it should come through transitively once FIRSupport has the right dependency.

I hope that made sense. Please feel free to ask me questions here or on the flang slack if I can help at all :)

@pawosm-arm pawosm-arm self-requested a review October 24, 2025 09:39
@JDPailleux
Copy link
Contributor Author

That was my conclusion. I was unable to reproduce the dependency issue on my side.
My only indication was the FIRSupport dependency in MIFDialect, and the MIFDialect header in "InitFIR.h" could produce the dependency error.
So, as @tblah mentions, removing the dependency from MIFDialect to FIRSupport makes the issue much less likely.

@pawosm-arm
Copy link
Contributor

So, as @tblah mentions, removing the dependency from MIFDialect to FIRSupport makes the issue much less likely.

Seems like flang suffers from a major design issue when it comes to specifying dependencies.

@tblah
Copy link
Contributor

tblah commented Oct 27, 2025

Seems like flang suffers from a major design issue when it comes to specifying dependencies.

This isn't a flang-specific design decision it is how MLIR dialects work - and I'm not sure using tablegen to create header files in LLVM is a bad design decision. However I agree that we would benefit from some tooling that verified these dependency graphs.

@JDPailleux
Copy link
Contributor Author

I added a dependency to MIFDialect in FIRSupport as discussed with @tblah

@pawosm-arm
Copy link
Contributor

I added a dependency to MIFDialect in FIRSupport as discussed with @tblah

So in the end, it's FIRSupport that needs MIFDialect, not the other way round.

@JDPailleux
Copy link
Contributor Author

Yes, that's right. I don't know why I added this dependency (perhaps an artifact from my first try).

Copy link
Contributor

@tblah tblah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@JDPailleux JDPailleux merged commit 1f65ab1 into llvm:main Oct 27, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang:fir-hlfir flang Flang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants